package cn.hackcloud.designpattern.iterator;

import java.util.Iterator;
import java.util.List;

public class OutputImpl {

	List<College> colleges;

	public OutputImpl(List<College> colleges) {
		super();
		this.colleges = colleges;
	}

	public void printCollege() {
		Iterator<College> iterator = colleges.iterator();
		while (iterator.hasNext()) {
			College next = iterator.next();
			System.out.println(next.getName());
			printDepartment(next.createIterator());
		}
	}

	public void printDepartment(Iterator iterator) {
		while (iterator.hasNext()) {
			Department next = (Department) iterator.next();
			System.out.println(next.getName());
		}
	}
}
